#ifndef CONVOLUTION_H
#define CONVOLUTION_H

#include <QImage>
#include "Defs.h"

enum GradientMode{HORIZONTAL, VERTICAL, ALL};
// add by xianxing
enum WaveType{HORIZONTAL_WAVE, VERTICAL_WAVE, CIRCLE_WAVE};

void compute(QImage &src, QImage &dst, int* operatorX, int* operatorY, int size, GradientMode mode);
QImage applyRobertsOperator(QImage &image, GradientMode mode);
QImage applyPrewittOperator(QImage &image, GradientMode mode);
QImage applySobelOperator(QImage &image, GradientMode mode);

QImage applyMeanFilter(QImage &image);
uchar  findMedian(uchar* srcs, int size);
QImage applyMedianFilter(QImage &image);

QImage applySpherize(qreal radius, qreal height, QImage src);
QImage applyPolarToRectangular(QImage src);
QImage applyRectangularToPolar(QImage src);
QImage applyWhirlix(int degree, QImage src);
/**
  * by xianxing
  * Wave Filter
  * paras : waveLength , amplitude , phase , type
  * that is : f(x) = Asin(wx + fi) ; A - amplitude , w - waveLength , fi - phase
  * type : Horizon , Vertical , Circle ( all sinx )
  */
QImage applyWave(uint waveLength, uint amplitude, double phase, uint type, QImage src);
QImage applySharpen(QImage &image);
QImage applyMosaic(int size, QImage src);
QImage applyLighting(QPoint location, int intensity, int radius, QImage src);

class GaussianFilter
{
public:
    GaussianFilter();

    void setRadius(int radius);
    void setSigma(double sigma);


    QImage applyGaussOperator(QImage &image);

private:
    int m_radius;
    double m_sigma;
    int m_diamet;
    double m_sigma2;
    double m_nuclear;
    double* m_gaussOperator;

    void computeGaussOperator();
};

#endif // CONVOLUTION_H
